Home:ALL Converter>Automatically log out user when they leave the iOS app

Automatically log out user when they leave the iOS app

Ask Time:2018-11-16T21:38:11         Author:Martin N

Json Formatter

I have an in-house app which is used by staff but the chances are the device it is used on could become consumer facing. With that in mind I want to ensure that should the staff forget to logout when they switch apps or just reopen the app that I have a command in there to effectively log them out.

After researching I think the best way for me would be to use:

optional func applicationWillEnterForeground(_ application: UIApplication)

and then force the app to go to the login page or the reverse so that when app enters background it forces the app to the logout URL.

Which do you think would be best and how can I use that command to then add in the chosen URL as described above?

Author:Martin N,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/53338982/automatically-log-out-user-when-they-leave-the-ios-app
yy